package com.blog.mapper;

import com.blog.model.Relationship;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 中间表的持久层
 *
 * @author wmb
 *
 * @since 2021-2-9
 */
@Mapper
@Repository("relationshipMapper")
public interface RelationshipMapper {

    /**
     * 获取数量
     *
     * @param cid
     * @param mid
     *
     * @return
     */
    Long getCountById(@Param("cid") Integer cid, @Param("mid") Integer mid);

    /**
     * 添加
     *
     * @param relationship
     *
     * @return
     */
    void saveRelationShip(Relationship relationship);

    /**
     * 根据文章编号删除关联
     *
     * @param cid
     *
     * @return
     */
    int deleteRelationshipByCid(@Param("cid") Integer cid);

    /**
     * 根据文章主键获取关联
     *
     * @param cid
     *
     * @return
     */
    List<Relationship> getRelationshipByCid(@Param("cid") Integer cid);

    /**
     *
     * 根据meta编号获取关联
     *
     * @param mid
     *
     * @return
     */
    List<Relationship> getRelationshipByMid(@Param("mid") Integer mid);

    /**
     * 根据meta编号删除关联
     *
     * @param mid
     *
     * @return
     */
    void deleteRelationshipByMid(@Param("mid") Integer mid);
}
